home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 129_01.zip / CLOG.C < prev    next >
Text File  |  1993-06-01  |  4KB  |  177 lines

  1. #define TITLE    "Display contents of the CITADEL log.     v2.1"
  2. /**
  3. ***    This program allows inspection of the Citadel log
  4. ***    displaying misc things about the user.
  5. ***    Modified by H.A. White, May 2, 1984.
  6. **/
  7.  
  8. #include <210ctdl.h>    /* header file    */
  9.  
  10. main(argc,argv)
  11. char **argv;
  12. {
  13.     int  index;
  14.     int i, entry, lstfl, pw;
  15.     char obuf[BUFSIZ];
  16.     
  17.     printf("%s\n",TITLE);
  18.     readsystab();
  19.     if ((logfl = open("ctdllog.sys",0)) == ERROR) {
  20.     printf("Can't open the Citadel log!\n");
  21.     exit();
  22.     }
  23.     pw = lstfl = 0;
  24.     index = 1;
  25.     while (argc >= 2) {
  26.     if (argv[index][0] == '-') {
  27.         if (argv[index][1] == 'D' || argv[index][2] == 'D') {
  28.         printf("Listing Log entries in: CTDLLOG.LST\n");
  29.         if ( (lstfl = fcreat("CTDLLOG.LST",obuf)) == ERROR) {
  30.             printf("Can't create CTDLLOG.LST file!\n");
  31.             exit();
  32.         }
  33.         fprintf(obuf,"%s\n",TITLE);
  34.         }
  35.         if (argv[index][1] == 'P' || argv[index][2] == 'P') {
  36.         printf("Listing Passwords.\n");
  37.         pw = TRUE;
  38.         }
  39.     }
  40.     argc--;
  41.     index++;
  42.     }
  43.     entry = 1;
  44.     for ( i = 0; i < MAXLOGTAB; i++ ) {
  45.     getlog(&logBuf,i);
  46.     if (lstfl)
  47.         fprintf(obuf,"log #%d",i);
  48.     printf("log #%d",i);
  49.     if (!nogood(i))
  50.         showlog(&logBuf,entry++,lstfl,obuf,pw); 
  51.     else {
  52.         putchar('\n');
  53.         if (lstfl)
  54.         fprintf(obuf,"\n");
  55.     }
  56.     }
  57.     if (lstfl) {
  58.     putc(CPMEOF,obuf);
  59.     fflush(obuf);
  60.     fclose(obuf);
  61.     }
  62. }
  63.  
  64. nogood(s)
  65. {
  66.     int i;
  67.  
  68.     for (i = 0; i < MAXLOGTAB; i++)
  69.     if (logTab[i].ltlogSlot == s)
  70.         break;
  71.     if (i == MAXLOGTAB) return TRUE;
  72.     if (logTab[i].ltpwhash != 0 &&
  73.     logTab[i].ltnmhash != 0)
  74.     return FALSE;
  75.     return TRUE;
  76. }
  77.  
  78. showlog(log,i,lst,buf,pw)
  79. struct logBuffer *log;
  80. int i,lst,pw;
  81. char *buf;
  82. {
  83.     int j;
  84.     char work[80],work2[80];
  85.     
  86.     sprintf(work,"%4d: %-20s",i,log->lbname);
  87.     if (pw) {
  88.     sprintf(work2,"%-20s",log->lbpw);
  89.     strcat(work,work2);
  90.     }
  91.     sprintf(work2," %sAide, %sExpert, %d col.\n",
  92.     log->lbflags & AIDE   ? "    " : "Not ", 
  93.     log->lbflags & EXPERT ? "    " : "Not ",
  94.     log->lbwidth);
  95.     strcat(work,work2);
  96.     printf("%s",work);
  97.     if (lst)
  98.     fprintf(buf,"%s",work);
  99. }
  100.  
  101. /*
  102.  *    getLog() loads requested log record into RAM buffer
  103.  */
  104. getlog(lBuf, n)
  105. struct logBuffer *lBuf;
  106. int n;
  107. {
  108.     int sec;
  109.     if (lBuf == &logBuf)
  110.     thisLog = n;
  111.  
  112.     n *= SECSPERLOG;
  113.  
  114.     seek(logfl, n, 0);
  115.     if ( (sec = read(logfl, lBuf, SECSPERLOG) ) != SECSPERLOG ) {
  116.     printf("?getLog-rread fail, request was for %d", n/SECSPERLOG);
  117.     exit(printf("\n%s", errmsg(errno())));
  118.     }
  119.     crypte(lBuf, (SECSPERLOG*SECTSIZE), n);    /* decode buffer    */
  120. }
  121.  
  122. dumpsec(p)
  123. char *p;
  124. {
  125.     char c;
  126.     int i,j;
  127.  
  128.     for ( i = 0; i < 8; i++) {
  129.     for (j = 0; j < 16; j++)
  130.         printf(" %02x",p[i*16+j]);
  131.     printf("  |");
  132.     for (j = 0; j < 16; j++) {
  133.         c = p[i*16+j];
  134.         if (c < ' ' || c > 128)
  135.         putchar('.');
  136.         else
  137.         putchar(c);
  138.     }
  139.     printf("|\n");
  140.     }
  141.     putchar('\n');
  142. }
  143.  
  144. crypte(buf, len, seed)
  145. char      *buf;
  146. unsigned  len, seed;
  147. {
  148.     seed = (seed + 0x553) & 0xFF;
  149.     for ( ; len; len--) {
  150.     *buf++ ^= seed;
  151.     seed = (seed + CRYPTADD)  &  0xFF;
  152.     }
  153. }
  154.  
  155. /*
  156. **   readSysTab() restores state of system from SYSTEM.TAB
  157. */
  158. readSysTab()
  159. {
  160.     char getc();
  161.     char fBuf[BUFSIZ];
  162.     char *c;
  163.  
  164.     if(fopen("ctdlTabl.sys", fBuf) == ERROR)
  165.     exit(printf("?no ctdlTabl.sys!"));
  166.  
  167.     getw(fBuf);
  168.     getw(fBuf);
  169.     c = &firstExtern;
  170.     while (c < &lastExtern)
  171.     *c++ = getc(fBuf);
  172.     return(TRUE);
  173. }
  174. fBuf);
  175.     return(TRUE);
  176. }
  177.